var mongoose     = require('mongoose');
// Connect to DB
// mongoose.connect(process.env.MONGO_URL);
mongoose.connect('mongodb://127.0.0.1:27017/MongoDB');
 // If the connection throws an error
mongoose.connection.on('error',function (err) {
  console.log('Mongoose default connection error: ' + err);
});
mongoose.connection.on('connected',function () {
  console.log('Mongoose  connection ok: ');
  

});
// When the connection is disconnected
mongoose.connection.on('disconnected', function () {
  console.log('Mongoose default connection disconnected');
});

// If the Node process ends, close the Mongoose connection
process.on('SIGINT', function() {
  mongoose.connection.close(function () {
    console.log('Mongoose default connection disconnected through app termination');
    process.exit(0);
  });
});


module.exports=mongoose;